package org.gdpu.model;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by HEWI2 on 1/22/14.
 */
@Entity
public class Mailbox {

    /**
     * 流水编号
     */
    private int id;
    /**
     * 姓名
     */
    private Student student;
    /**
     * 主题
     */
    private String title;
    /**
     * 留言
     */
    private String message;
    /**
     * 发布时间
     */
    private Date publishDate;
    /**
     * 回复时间
     */
    private Date replyDate;
    /**
     * 回复
     */
    private String replyMessage;
    /**
     * 信箱状态
     */
    private MailboxState mailboxState;
    /**
     * 回复人
     */
    private User user;

    @ManyToOne
    @JoinColumn(name = "userId")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Temporal(TemporalType.TIMESTAMP)
    public Date getReplyDate() {
        return replyDate;
    }

    public void setReplyDate(Date replyDate) {
        this.replyDate = replyDate;
    }

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "student", nullable = false)
    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @Column(nullable = false, length = 40)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Column(nullable = false)
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false)
    public Date getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Date publishDate) {
        this.publishDate = publishDate;
    }

    public String getReplyMessage() {
        return replyMessage;
    }

    public void setReplyMessage(String replyMessage) {
        this.replyMessage = replyMessage;
    }

    @Enumerated(EnumType.ORDINAL)
    @Column(nullable = false, columnDefinition = "INT default 1", length = 2)
    public MailboxState getMailboxState() {
        return mailboxState;
    }

    public void setMailboxState(MailboxState mailboxState) {
        this.mailboxState = mailboxState;
    }
}
